<!DOCTYPE html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<title>我的发布</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />

    <style>
    	html, body {width: 100%;min-height: 100%;background: #f0f0f0;}
    	.h20 {height: 0.5rem;background: #f0f0f0;}


		/* 数据 */
		.enshrine .aui-list-item-title {
			color: #333;
			line-height: 1rem;
			font-size: 0.75rem;
		}
		.enshrine .aui-info-item {
				color: #999;
				font-size: 0.6rem;
		}
		.enshrine .aui-list-item-media {
			width: 6.5rem;
		}
    .aui-list .registration_txtBot {
      color: #ff9800;
			font-size: 0.6rem;
			line-height: 1;
			height: 0.6rem;
      position: relative;
      width: 100%;
    }
    .registration_txtBot span {
      position: absolute;
      right: 0;
      top: 0;
      color: #ff9800;
    }
		.enshrine .aui-media-list .aui-list-item-inner {
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
			-webkit-box-orient: vertical;
			box-orient: vertical;
			-webkit-flex-direction: column;
			flex-direction: column;
			-webkit-box-pack: justify;
			-webkit-justify-content: space-between;
			justify-content: space-between;
			-webkit-box-align: start;
			-webkit-align-items: flex-start;
			align-items: flex-start;
		}
		.lwlx span {
			color: #999;
			margin-right: 30px;
			margin-left: 3px;
		}
		.lwTitle {
			margin-bottom: 5px;
		}


		.xsTab .aui-tab-item {
      border: none;
      position: relative;
      color: #999;
    }
    .xsTab .aui-tab-item:after {
      content: '';
      display: block;
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      width: 50%;
      height: 2px;
      background: #fff;
      margin: auto;
    }
    .xsTab .aui-tab-item.aui-active {
      color: #2997e4;
    }
    .xsTab .aui-tab-item.aui-active:after {
      background: #2997e4;
    }
		.xsBox {
			display: none;
		}
		.itemIco {
			height: 4rem;
			width: 100%;
		}
		#xsTab {
			position: fixed;
			width: 100%;
			top:0;
			z-index: 99;
		}
		body {
			padding-top: 40px;
		}
    </style>
</head>
<body>
	<div id="app" v-cloak>
		<div class="aui-tab xsTab" id="xsTab">
	    <div class="aui-tab-item aui-active">我的活动</div>
	    <div class="aui-tab-item">我的论文</div>
	  </div>


		<section class="aui-refresh-content">
		<div class="xsBox" style="display: block;">
				<div class="h20"></div>
			<div class="aui-content aui-margin-b-15 enshrine">
			 <ul class="aui-list aui-media-list">
					 <li v-if="item.type == 1" class="aui-list-item" v-for="item in data" tapmode="presshover" @click="openNewWindow(item.newsId,'fb_activitydetails','活动详情')">
							 <div class="aui-media-list-item-inner">
									 <div class="aui-list-item-media">
                        <div v-if="item.pics && item.pics!=null" class="itemIco" :style="'background: url('+ item.pics +') center/cover no-repeat'"></div>
     										<div v-else class="itemIco" style="background: url(../../image/banner3@3x.png) center/cover no-repeat"></div>
									 </div>
									 <div class="aui-list-item-inner">
											 <div class="aui-list-item-text">
													 <div class="aui-list-item-title">{{item.title}}</div>
											 </div>
											 <div class="aui-info aui-margin-t-5" style="padding: 0;">
													 <div class="aui-info-item">{{item.createTime}}</div>
											 </div>
									 </div>
							 </div>
					 </li>
			 </ul>
			</div>
		</div>

		<div class="xsBox">
				<div class="h20"></div>
			<div class="aui-content aui-margin-b-15 enshrine">
			 <ul class="aui-list aui-media-list">
					 <li v-if="item.type == 2" class="aui-list-item" v-for="item in data" tapmode="presshover" @click="openNewWindow(item.id,'five_detail_lw','详情')">
							 <div class="aui-media-list-item-inner">
									 <div class="aui-list-item-inner">
											 <div class="aui-list-item-text">
													 <div class="aui-list-item-title lwTitle">{{item.title}}</div>
											 </div>
											 <div class="aui-info aui-margin-t-5" style="padding: 0;">
													 <div class="aui-info-item lwlx"><span>{{item.actype | name}}</span>发布于{{item.create_date}}</div>
											 </div>
									 </div>
							 </div>
					 </li>
			 </ul>
			</div>
		</div>
</section>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script src="../../script/aui-tab.js"></script>
<script src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript">

	apiready = function() {

    var app = new Vue({
      el: '#app',
      data: {
        data: [],
        token: '',
      },
      created: function() {
        var $_this = this;
        $_this.token = $api.getStorage('token') || '';

				if(!$api.getStorage('token')){
	        api.confirm( {
	            title: '是否登录',
	            msg: '确认是否登录？',
	            buttons: [ '确定', '取消' ]
	          }, function ( ret, err ) {
	            var index = ret.buttonIndex;
	            if ( index == 1 ) {
	              api.openWin({
	                name: 'login',
	                url: '../five_frame/login_header.html',
	                delay: 200,
	                bounces: false
	              });
	              return;
	            } else {
	              api.closeWin({
	                  name: name
	              });
	              return
	            }
	          })
	          return
	        }
        api.ajax({
         url: window.Url.myRelease,
         headers: {
             'baseParams':$api.getStorage('token') //token
         },
         timeout: 300,
       	}, function(ret, err) {
						console.log( $api.getStorage('token') );
						if (ret.code == 2) {
                  alert('用户未登录，请返回登录')
                  $api.rmStorage('token')
                  $api.rmStorage('data')
                  goback()
                   return
                }else if (ret.code == 0) {
             if (ret.data != '') {
               $_this.data = ret.data;
             }
           } else {
               api.alert({ msg: JSON.stringify(err) });
           }
       })
      },
      filters: {
  		  name: function (value) {
					var name = null;
  		    switch(value){
						case '1':{name = "文学论文";break;}
						case '2':{name = "教育论文";break;}
						case '3':{name = "建筑论文";break;}
						case '4':{name = "电子论文";break;}
						case '5':{name = "经济论文";break;}
						case '6':{name = "工业论文";break;}
						case '7':{name = "社科论文";break;}
					}
					return name;
  		  }
  		},
      methods: {
        openLogin:function (){
  				api.openWin({
  					name: 'login',
  					url: './login_header.html',
  					bounces: false,
  					delay:200
  				});
  			},
        openNewWindow:function (id,type,title){
        		api.openWin({
        			name: type,
        			url: './forth_header.html',
        			pageParam: {id: id,name: type,title: title},
        			bounces: false,
        			delay:200
        		});
        }
      },
			mounted: function () {
				var tab = new auiTab({
					element:document.getElementById("xsTab"),
					index:1,
					repeatClick:false
				},function(ret){
					var xsBox = document.querySelectorAll('.xsBox')
					for (var i = 0; i < xsBox.length; i++) {
						xsBox[i].style.display = 'none'
					}
					document.querySelectorAll('.xsBox')[ret.index - 1].style.display = 'block'
				})

				var $_this = this;
		    var pullRefresh = new auiPullToRefresh({
		        container: document.querySelector('.aui-refresh-content'),
		        triggerDistance: 100
		    },function(ret){
		        if(ret.status=="success"){
							api.ajax({
							 url: window.Url.myRelease,
							 method: 'GET',
							 headers: {
									 'baseParams':$_this.token
							 },
							 timeout: 300,
							}, function(ret, err) {
									// api.alert({ msg: JSON.stringify(ret) });
								 if (ret.code == 0) {
								 setTimeout(function() {
									 if (ret.data != '') {
										 $_this.data = ret.data;
									 }
										 pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
									 },500)
								 } else {
										 api.alert({ msg: JSON.stringify(err) });
								 }
						 })

		        }
		    })
			}
    })
  }
	function goback () {
	    api.closeWin({name:api.pageParam.name});
	  }
</script>
</html>
